package com.ruoyi.project.sdi.sdiImage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.paea.paeaDsTrade.domain.PaeaDsTrade;
import com.ruoyi.project.sdi.sdiImage.domain.SdiImage;
import com.ruoyi.project.sdi.sdiImage.mapper.SdiImageMapper;
import com.ruoyi.project.sdi.sdiImage.service.ISdiImageService;
import com.ruoyi.project.sdi.sdiPaeaArc.domain.SdiPaeaArc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 影像表Service业务层处理
 *
 * @author 关晓强
 * @date 2020-03-16
 */
@Service
public class SdiImageServiceImpl extends ServiceImpl<SdiImageMapper, SdiImage> implements ISdiImageService
{
    @Autowired
    private SdiImageMapper sdiImageMapper;

    /**
     * 查询影像表
     *
     * @param id 影像表ID
     * @return 影像表
     */
    @Override
    public SdiImage selectSdiImageById(String id)
    {
        return sdiImageMapper.selectSdiImageById(id);
    }

    /**
     * 查询影像表列表
     *
     * @param sdiImage 影像表
     * @return 影像表
     */
    @Override
    public List<SdiImage> selectSdiImageList(SdiImage sdiImage)
    {
        return sdiImageMapper.selectSdiImageList(sdiImage);
    }

    /**
     * 新增影像表
     *
     * @param sdiImage 影像表
     * @return 结果
     */
    @Override
    public int insertSdiImage(SdiImage sdiImage)
    {
        return sdiImageMapper.insertSdiImage(sdiImage);
    }

    /**
     * 修改影像表
     *
     * @param sdiImage 影像表
     * @return 结果
     */
    @Override
    public int updateSdiImage(SdiImage sdiImage)
    {
        return sdiImageMapper.updateSdiImage(sdiImage);
    }

    /**
     * 删除影像表对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSdiImageByIds(String ids)
    {
        return sdiImageMapper.deleteSdiImageByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除影像表信息
     *
     * @param id 影像表ID
     * @return 结果
     */
    @Override
    public int deleteSdiImageById(String id)
    {
        return sdiImageMapper.deleteSdiImageById(id);
    }

    /**
     * 查询批次的影像列表
     * @param sdiPaeaArc
     * @return
     */
    @Override
    public List<SdiImage> getSdiImagesBySdiPaeaArc(SdiPaeaArc sdiPaeaArc) {
        return this.list(new QueryWrapper<SdiImage>()
                .eq("arc_id",sdiPaeaArc.getId())
                .orderByAsc("index_no"));
    }

    /**
     * 获取流水的影像列表
     *
     * @param paeaDsTrade
     * @return
     */
    @Override
    public List<SdiImage> getSdiImagesByPaeaDsTrade(PaeaDsTrade paeaDsTrade) {
        return this.list(new QueryWrapper<SdiImage>()
                .eq("parent_id",paeaDsTrade.getImageId())
                .orderByAsc("index_no"));
    }

    @Override
    public void batchUpdateSdiImages(List<SdiImage> sdiImageList) {
        this.sdiImageMapper.batchUpdateSdiImages(sdiImageList);
    }
}
